import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class t15_3 {//双指针
    public static void main(String[] args) {
        long srt = System.currentTimeMillis();
        int arr[] = {13, -14, -10, -4, 4, 4, 0, -14, 5, -9, -3, -10, 14, 7, -3, -4, -3, 12, -14, 2, -11, -6, 0, -7, 13, -2, -7, -11, -14, -13, 5, 14, -12, 11, -13, -1, -8, 2, 0, 4, 1, 4, 10, -8, -11, -8, 3, 1, 11, 4, -12, 8, 5, -4, -14, -4, 9, -13, -8, 2, -11, 12, -7, 14, 0, -5, -2, 7, 5, 5, -3, 13, -6, -8, -10, -10, -9, 0, 6, -12, 11, 2, 11, 1, 13, 4, 12, -1, 6, -11, -14, 2, 9, -6, 1, -6, -4, 14, -13, 8, 4, -1, 6, 6, -2, 11, 11, 4, -4, -5, -1, -8, 12, -13, 1, 10, 7, -10, -14, -10, -5, -13, 0, 11};
        //int arr[] ={-1,0,1,2,-1,-4};
        System.out.println(test(arr).size());
        long ed = System.currentTimeMillis();
        System.out.println(ed - srt + "ms");
    }

    public static List<List<Integer>> test(int arr[]) {
        List<List<Integer>> list = new ArrayList<>();
        Arrays.sort(arr);
        for (int i = 0; i < arr.length; i++) {
            if(i>0&&arr[i]==arr[i-1]){
                continue;
            }
            int k = arr.length-1;
            for(int j = i+1;j<arr.length;j++){
                if(j>i+1&&arr[j]==arr[j-1]){
                    continue;
                }
                while (j<k && arr[j]+arr[k]>-arr[i]){//寻找最近最可能的k
                    k--;
                }
                if(j == k){
                    break;
                }
                if(arr[j]+arr[k]==-arr[i]){
                    List<Integer> list1 = new ArrayList<Integer>();
                    list1.add(arr[i]);
                    list1.add(arr[j]);
                    list1.add(arr[k]);
                    list.add(list1);

                }
            }
        }
        return list;










    }

}
